import { IncomingHttpHeaders } from 'http';
import doc_code from '@dfeidao/atom-nodejs/msg/doc-code';
import { systemid, productid } from '../../atom/config';
import operate from '@dfeidao/atom-nodejs/db/operate';
interface Message {
	filter: {
		risk_level: string,
		risk_po_type_name: string,
	}
}

// interface IWebResult {
// 	data: unknown;
// 	cookie?: {
// 		[name: string]: string;
// 	} | null;
// 	content_type?: string;
// 	headers?: {
// 		[key: string]: string;
// 	};
// 	attachment?: string;
// 	redirect?: string;
// 	status_code?: number;
// }

export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	//保存数据
	const bian = await doc_code(action_id, session_id, systemid, 'BM0014340', '', 1);
	const { exec, insert } = operate(action_id, session_id, systemid);
	insert('risk_point_type', {
		risk_po_type_no: bian.result,
		risk_po_type_name: message.filter.risk_po_type_name,
		risk_level: message.filter.risk_level,
		productid
	});

	const ret = await exec();
	return {
		data: ret
	}
}
